package shared.message.query

import shared.message._
import shared.query._
import shared.file._

case class QueryMessage (val query: Query) extends IdentifiedMessage[QueryResponse] {
  def handle(fs: Filesystem) = fs.queryFiles(query).map( QueryResponse(_, this.id))
}

case class QueryResponse(val ref: FileReference, val responseTo: Long) extends ResponseMessage with java.io.Serializable {
}

class EnquiryResponse(fs: Filesystem, val responseTo: Long) extends ResponseMessage with java.io.Serializable {
  val files = fs.allFiles.map( _.toRemote )
}

class EnquiryMessage extends IdentifiedMessage[EnquiryResponse] {
  def handle(fs: Filesystem) = new EnquiryResponse(fs, this.id)
}